<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Model\Admin\MessageModel;
use Illuminate\Http\Request;

class MessageController extends Controller
{
    //

    /**
     * 留言列表
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        return view('admin.message.index');
    }

    /**
     * 获取列表数据
     *
     * @param Request $request
     * @return mixed
     */
    public function getList(Request $request)
    {
        $page = $request->page ? : 1;
        $limit = $request ->limit ? : 10;

        $data['code'] = 0;
        $data['msg'] = '成功';

        $Message = new MessageModel();
        $data['count'] = $Message->count();
        $data['data'] = $Message
            ->skip($limit * ($page - 1))
            ->take($limit)
            ->get();
        return $data;
    }


    public function show(Request $request, $id)
    {
        $Message = new MessageModel();
        $data = $Message -> findOrfail($id);
        return view('admin.message.show')->with('data',$data);
    }
}
